/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lucava.boatskeeper.server.handler.user;

import net.customware.gwt.dispatch.server.ActionHandler;
import net.customware.gwt.dispatch.server.ExecutionContext;
import net.customware.gwt.dispatch.shared.ActionException;
import org.lucava.boatskeeper.server.MockBoatDao;
import org.lucava.boatskeeper.server.MockUserDao;
import org.lucava.boatskeeper.shared.rpc.user.DeleteUsers;
import org.lucava.boatskeeper.shared.rpc.user.DeleteUsersResult;

/**
 *
 * @author glenn
 */
public class DeleteUsersHandler implements ActionHandler<DeleteUsers, DeleteUsersResult> {

    @Override
    public Class<DeleteUsers> getActionType() {
        return DeleteUsers.class;
    }

    @Override
    public DeleteUsersResult execute(DeleteUsers a, ExecutionContext ec) throws ActionException {

        for (Integer id : a.getList()) {
            MockBoatDao.delete(MockBoatDao.get(id));
        }
        DeleteUsersResult deleteUsersResult = new DeleteUsersResult(MockUserDao.getAll());
        return deleteUsersResult;
    }

    @Override
    public void rollback(DeleteUsers a, DeleteUsersResult r, ExecutionContext ec) throws ActionException {
    }
}
